package com.unionpay.qPBOC;

/*
 * AIP  : Application Interchange Profile
 * (x)  : A Pointer to the AIP <2 bytes>
 * Macro:
   AIP_SDA_Support : SDA supported
   AIP_DDA_Support : DDA supported
   AIP_CV_Support  : CardHolder Verification supported
   AIP_TRM_Support : Terminal Risk Management is to be performed
   AIP_IA_Support  : Issuer authentication supported
   AIP_CDA_Support : CDA supported

 * EMV 4.1 Book3.PartIV.Annex C.C1
 */
public class AIPUtil {
	public static boolean AIP_SDA_Support(byte [] aip) {
		if ( ((aip[0] & 0xFF) & 0x40) == 0x40) {
			return true;
		}
		
		return false;
	}
	
	public static boolean AIP_DDA_Support(byte [] aip) {
		if ( ((aip[0] & 0xFF) & 0x20) == 0x20) {
			return true;
		}
		
		return false;
	}
	
	public static boolean AIP_CV_Support(byte [] aip) {
		if ( ((aip[0] & 0xFF) & 0x10) == 0x10) {
			return true;
		}
		
		return false;
	}
	
	public static boolean AIP_TRM_Support(byte [] aip) {
		if ( ((aip[0] & 0xFF) & 0x08) == 0x08) {
			return true;
		}
		
		return false;
	}

	public static boolean AIP_IA_Support(byte [] aip) {
		if ( ((aip[0] & 0xFF) & 0x04) == 0x04) {
			return true;
		}
		
		return false;
	}
	
	public static boolean AIP_CDA_Support(byte [] aip) {
		if ( ((aip[0] & 0xFF) & 0x01) == 0x01) {
			return true;
		}
		
		return false;
	}
	
	public static boolean AIP_MSD_Support(byte [] aip) {
		if ( ((aip[1] & 0xFF) & 0x80) == 0x80) {
			return true;
		}
		
		return false;
	}
	
}
